<template>
  <el-form class="add-event-general" v-if="wbData">
    <el-divider content-position="center">通用接口数据</el-divider>
    <dropdown-normal v-model="wbData.ele_key" :valLists="GENERAL_TYPES" label="通用接口类型" :bIsBtn="false" @change="onUpdateWbComponent" ></dropdown-normal>
    <input-normal label="关联触发组件id" v-model="wbData.relateCompId" @change="onUpdateWbComponent"></input-normal>
    <input-normal label="关联获取组件id" v-model="wbData.getCompId" @change="onUpdateWbComponent"></input-normal>
    <input-normal label="扩展属性1" v-model="wbData.ext_1" @change="onUpdateWbComponent"></input-normal>
    <input-normal label="扩展属性2" v-model="wbData.ext_2" @change="onUpdateWbComponent"></input-normal>
    <input-normal label="扩展属性3" v-model="wbData.ext_3" @change="onUpdateWbComponent"></input-normal>
    <input-normal label="扩展属性4" v-model="wbData.ext_4" @change="onUpdateWbComponent"></input-normal>
    <input-normal label="扩展属性5" v-model="wbData.ext_5" @change="onUpdateWbComponent"></input-normal>
    <input-normal label="扩展字段key" v-model="wbData.ext_key" @change="onUpdateWbComponent"></input-normal>
  </el-form>
</template>

<script setup lang="ts">
import { useWebControlsStore } from '@/store/web/controls'
import { GENERAL_TYPES } from '@/const/'

const props = defineProps<{ 
  event: IEvent,
  index: number,
}>()

const event = props.event
const useWebControls = useWebControlsStore()


let wbData_: any
const wbData = computed(() => {
  try {
    wbData_ = useWebControls.currentControls![event.controlId] && useWebControls.currentControls![event.controlId].data
  } catch (error) {
    console.log("controlData.data null")
  }
  return wbData_
})
const onUpdateWbComponent = () => {
  useWebControls.updateWbComponent({ controlId: event.controlId, data: wbData_ })
}
</script>
